﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Canyala.Lagoon.Effects
{
    public class ShowEffect
    {
        public static void Animate(FrameworkElement target, int speedRatio, Action finished = null)
        {
            Storyboard sb = new Storyboard();
            
            var animation = new DoubleAnimation
            {
                From = 0,
                To = 1,
                SpeedRatio = speedRatio
            };

            Storyboard.SetTarget(animation, target);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.Opacity)"));

            sb.Children.Add(animation);

            if (finished != null)            
                sb.Completed += (s, e) => finished.Invoke();
            

            sb.Begin();
        }
    }
}
